import wmi #wmi relies on pywin32 adn wmi

s=wmi.WMI()


#https://learn.microsoft.com/zh-cn/windows/win32/cimwin32prov

#硬盘信息
def get_disk_info():
    diskinfo=[]
    disknum=0
    for disk in s.Win32_DiskDrive():
        
        diskinfo.append(
            {
                "no.1":disk.Availability,
                "no.2":disk.BytesPerSector,
                "no.3":disk.Caption,#'Fanxiang S500PRO 2TB'
                "no.4":disk.CompressionMethod,
                "no.5":disk.ConfigManagerErrorCode,
                "no.6":disk.ConfigManagerUserConfig,
                "no.7":disk.CreationClassName,
                "no.8":disk.DefaultBlockSize,
                "no.9":disk.Description,
                "no.10":disk.DeviceID,
                "no.11":disk.ErrorCleared,
                "no.12":disk.ErrorDescription,
                "no.13":disk.ErrorMethodology,
                "no.14":disk.FirmwareRevision,
                "no.15":disk.Index,
                "no.16":disk.InstallDate,
                "no.17":disk.InterfaceType,
                "no.18":disk.LastErrorCode,
                "no.19":disk.Manufacturer,
                "no.20":disk.MaxBlockSize,
                "no.21":disk.MaxMediaSize,
                "no.22":disk.MediaLoaded,
                "no.23":disk.MediaType,
                "no.24":disk.MinBlockSize,
                "no.25":disk.Model,
                "no.26":disk.Name,
                "no.27":disk.NeedsCleaning,
                "no.28":disk.NumberOfMediaSupported,
                "no.29":disk.Partitions,
                "no.30":disk.PNPDeviceID,
                "no.31":disk.PowerManagementSupported,
                "no.32":disk.SCSIBus,
                "no.33":disk.SCSILogicalUnit,
                "no.34":disk.SCSIPort,
                "no.35":disk.SCSITargetId,
                "no.36":disk.SectorsPerTrack,
                "no.37":disk.SerialNumber,
                "no.38":disk.Signature,
                "no.39":disk.Size,#大小
                "no.30":disk.Status,
                "no.41":disk.StatusInfo,
                "no.42":disk.SystemCreationClassName,
                "no.43":disk.SystemName,
                "no.44":disk.TotalCylinders,
                "no.45":disk.TotalHeads,
                "no.46":disk.TotalSectors,
                "no.47":disk.TotalTracks,
                "no.48":disk.TracksPerCylinder
            }
        )
        disknum+=1
    return diskinfo

print(get_disk_info())

#'no.1': None, 'no.2': 512, 'no.3': 'Fanxiang S500PRO 2TB', 'no.4': None, 'no.5': 0, 'no.6': False, 'no.7': 'Win32_DiskDrive', 'no.8': None, 'no.9': '磁盘驱动器', 'no.10': '\\\\.\\PHYSICALDRIVE0', 'no.11': None, 'no.12': None, 'no.13': None, 'no.14': 'SN10613', 'no.15': 0, 'no.16': None, 'no.17': 'SCSI', 'no.18': None, 'no.19': '(标准磁盘驱动器)', 'no.20': None, 'no.21': None, 'no.22': True, 'no.23': 'Fixed hard disk media', 'no.24': None, 'no.25': 'Fanxiang S500PRO 2TB', 'no.26': '\\\\.\\PHYSICALDRIVE0', 'no.27': None, 'no.28': None, 'no.29': 3, 'no.30': 'OK', 'no.31': None, 'no.32': 0, 'no.33': 0, 'no.34': 0, 'no.35': 0, 'no.36': 63, 'no.37': '0000_0000_0000_0001.', 'no.38': None, 'no.39': '2048407280640', 'no.41': None, 'no.42': 'Win32_ComputerSystem', 'no.43': 'W11-20231023545', 'no.44': '249038', 'no.45': 255, 'no.46': '4000795470', 'no.47': '63504690', 'no.48': 255